home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 1.iso / ARGONET / PD / PROGRAMMING / DESKLIBC / SOURCES.ZIP / DeskLib / !DLSources / Libraries / Window / c / SetTitle < prev    next >
Text File  |  1995-07-08  |  2KB  |  64 lines

  1. /*
  2.     ####             #    #     # #
  3.     #   #            #    #       #          The FreeWare C library for 
  4.     #   #  ##   ###  #  # #     # ###             RISC OS machines
  5.     #   # #  # #     # #  #     # #  #   ___________________________________
  6.     #   # ####  ###  ##   #     # #  #                                      
  7.     #   # #        # # #  #     # #  #    Please refer to the accompanying
  8.     ####   ### ####  #  # ##### # ###    documentation for conditions of use
  9.     ________________________________________________________________________
  10.  
  11.     File:    Window.c.SetTitle
  12.     Author:  Copyright © 1993 Jason Williams
  13.     Version: 1.00 (28 Jun 1993)
  14.     Purpose: Set the text in a window's titlebar, and force a redraw of
  15.              the *correct* region of the screen to update it.
  16.              (i.e. it even works with Edouard Poor's MegaWindow toolsprites!)
  17. */
  18.  
  19. #include <string.h>
  20.  
  21. #include "DeskLib:Wimp.h"
  22. #include "DeskLib:WimpSWIs.h"
  23. #include "DeskLib:Window.h"
  24.  
  25.  
  26.  
  27. extern void Window_SetTitle(window_handle window, char *title)
  28. {
  29.   window_info        info;
  30.   window_redrawblock redraw;
  31.   window_outline     outline;
  32.   char               *buffer;
  33.   int                bufflen;
  34.  
  35.   /* Get the wimp information for this window */
  36.   Window_GetInfo(window, &info);
  37.  
  38.   if (!info.block.titleflags.data.indirected)
  39.     return;                /* We can't set the title if it isn't indirected! */
  40.  
  41.   buffer  = info.block.title.indirecttext.buffer;
  42.   bufflen = info.block.title.indirecttext.bufflen - 1;
  43.  
  44.   /* Copy the given string into the window's title bar string */
  45.   strncpy(buffer, title, bufflen);
  46.   buffer[bufflen] = 0;              /* And ensure it is correctly terminated */
  47.  
  48.   if (info.block.flags.data.open)   /* *IF* window open, redraw the titlebar */
  49.   {
  50.     /* Get the position of the window on screen */
  51.     outline.window = window;
  52.     Wimp_GetWindowOutline(&outline);
  53.  
  54.     /*  Force a redraw of the title bar - it is the rectangle that lies
  55.      *  between the window outline as returned by Wimp_GetWindowOutline and
  56.      *  the window screenrect as returned by Wimp_GetWindowInfo
  57.      */
  58.     redraw.window     = -1;                        /* invalidate screen area */
  59.     redraw.rect       = outline.screenrect;
  60.     redraw.rect.min.y = info.block.screenrect.max.y;
  61.     Wimp_ForceRedraw(&redraw);
  62.   }
  63. }
  64.